package com.henanuniversity.controller;

import com.henanuniversity.po.Orders;
import com.henanuniversity.service.OrdersService;
import com.henanuniversity.service.impl.OrdersServiceImpl;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

public class OrdersController {
    public Object createOrders(HttpServletRequest request, HttpServletResponse response){
        String userId=request.getParameter("userId");
        Integer businessId=Integer.valueOf(request.getParameter("businessId"));
        Integer daId=Integer.valueOf(request.getParameter("daId"));
        OrdersService ordersService=new OrdersServiceImpl();
        int rows = ordersService.createOrders(userId, businessId, daId);
        return rows;
    }

    public Object getOrderById(HttpServletRequest request, HttpServletResponse response){
        Integer orderId=Integer.valueOf(request.getParameter("orderId"));
        OrdersServiceImpl service = new OrdersServiceImpl();
        Orders orders = service.getOrdersById(orderId);
        return orders;
    }

    public List<Orders> listOrderByUserId(HttpServletRequest request,HttpServletResponse response){
        String userId=request.getParameter("userId");
        OrdersServiceImpl service = new OrdersServiceImpl();
        List<Orders> list = service.listOrderByUserId(userId);
        return list;
    }
}
